<?php
class Scheduler{
	var $sock;
        var $domain;
	function __construct($port = 4080 ){
		$this->sock = pfsockopen("localhost", $port, $errno, $errstr);
		if (!$this->sock) 
			syslog("ERROR: $errno - $errstr");
	} 

	function __destruct() {
	} 

	function Event(){
		$input = 'S'."\001";
		fwrite($this->sock, $input);
		$readlen = $READ = 1024;
		return true;
	}
}

list($start_usec, $start_sec) = explode(" ", microtime());
$start_time = ((float) $start_usec + (float) $start_sec);

for($i=0; $i< 2; $i++)
{
	$a = rand();
//	if($a%10== 1)
	{
		echo "Event\n";
		$obj = new Scheduler(7080);
		$obj->Event();
	}
        usleep(100);
}
list($end_usec, $end_sec) = explode(" ", microtime());
$end_time = ((float) $end_usec + (float) $end_sec);
$total_time = 1000*($end_time - $start_time);
echo "<BR>总计耗时：".$total_time."毫秒 <BR>";

?>
